package com.blog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blog.service.entity.User;
import com.blog.service.inter.UserService;
import com.blog.service.model.UserMapper;

/**
 * 文件名： com.blog.service.impl.UserServiceImpl.java
 * 作者： WenBin
 * 日期： 2017年4月12日
 * 功能说明： 用户服务类
 * =========================================================
 * 修改记录：
 * 修改作者 日期 修改内容
 * =========================================================
 * Copyright (c) 2010-2011 .All rights reserved.
 */
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;

	@Override
	public User findUserByPk(String pk) {

		return userMapper.selectByPrimaryKey(pk);
	}

	@Override
	public User saveUser(User user) {

		int i = userMapper.insertSelective(user);
		if (i > 0) {
			return user;
		}
		return null;
	}

	@Override
	public User updateUser(User user) {

		int i = userMapper.updateByPrimaryKey(user);
		if (i > 0) {
			return user;
		}
		return null;
	}

	@Override
	public User findUserByLoginAccount(String account) {
		User user = userMapper.findUserByLoginAccount(account);
		return user;
	}

}
